/*
 * led.c
 *
 *  Created on: 29/gen/2014
 *      Author: Postazione Embedded
 */

#include "leds.h"

void gpioLedsConfiguration(){
	InitGPIO(GPIOLED, LEDS, GPIO_Mode_OUT, GPIO_PuPd_NOPULL, GPIO_Speed_50MHz);
	GPIO_ResetBits(GPIOLED, LEDS);
}

void writeLeds(uint16_t ledValues){
	GPIO_ResetBits(GPIOLED, LEDS);
	GPIO_SetBits(GPIOLED, ledValues);
}

void toggleLeds(uint16_t ledMask){
	uint16_t val = GPIO_ReadInputData(GPIOLED);
	GPIO_SetBits(GPIOLED, (~val) & ledMask);
	GPIO_ResetBits(GPIOLED, (val & ledMask));
}

